package com.starview.star.operators.arith.runtime;

import com.starview.platform.data.EvaluationException;
import com.starview.platform.data.IFunction;
import com.starview.platform.data.IValue;
import com.starview.platform.data.type.IType;
import com.starview.platform.data.type.StandardTypes;
import com.starview.platform.data.type.TypeUtils;
import com.starview.platform.data.value.BoolWrap;
import com.starview.platform.data.value.Factory;
import com.starview.star.operators.CafeEnter;



public abstract class FloatCompare
{
  private static final IType floatType = StandardTypes.rawFloatType;

  public static class FloatEQ implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 == ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

  public static class FloatNE implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 != ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

  public static class FloatLE implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 <= ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

  public static class FloatLT implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 < ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

  public static class FloatGT implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 > ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

  public static class FloatGE implements IFunction
  {
    @CafeEnter
    public static BoolWrap enter(double ix1, double ix2)
    {
      return Factory.newBool(ix1 >= ix2);
    }

    @Override
    public IType getType()
    {
      return TypeUtils.functionType(floatType, floatType, StandardTypes.booleanType);
    }

    @Override
    public IValue enter(IValue... args) throws EvaluationException
    {
      return enter(Factory.fltValue(args[0]), Factory.fltValue(args[1]));
    }
  }

}
